home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_kdelibs.idb / usr / freeware / kde / include / kdatetbl.h.z / kdatetbl.h
Encoding:
C/C++ Source or Header  |  1999-01-26  |  3.4 KB  |  108 lines

  1. /*  -*- C++ -*-
  2.     This file is part of the KDE libraries
  3.     Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org)
  4.               (C) 1998 Mirko Sucker (mirko.sucker@hamburg.netsurf.de)
  5.     This library is free software; you can redistribute it and/or
  6.     modify it under the terms of the GNU Library General Public
  7.     License as published by the Free Software Foundation; either
  8.     version 2 of the License, or (at your option) any later version.
  9.  
  10.     This library is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.     Library General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU Library General Public License
  16.     along with this library; see the file COPYING.LIB.  If not, write to
  17.     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  18.     Boston, MA 02111-1307, USA.
  19. */
  20. #ifndef _KDATETBL_H 
  21. #define _KDATETBL_H
  22.  
  23. /////////////////// KDateTable widget class //////////////////////
  24. //
  25. // Copyright (C) 1997 Tim D. Gilman
  26. //           (C) 1998 Mirko Sucker
  27. // Written using Qt (http://www.troll.no) for the
  28. // KDE project (http://www.kde.org)
  29. //
  30. // This is a support class for the KDatePicker class.  It just
  31. // draws the calender table without titles, but could theoretically
  32. // be used as a standalone.
  33. //
  34. // When a date is selected by the user, it emits a signal: 
  35. //      dateSelected(QDate)
  36.  
  37. #include <qtablevw.h>
  38. #include <qdatetm.h>
  39. #include <qsize.h>
  40.  
  41. /**
  42.   * Draws a calendar table.
  43.   * @author Tim D. Gilman
  44.   * @version $Id: kdatetbl.h,v 1.4 1998/05/28 19:52:16 kalle Exp $
  45.   */
  46.  
  47. class KDateTable: public QTableView {
  48.   Q_OBJECT
  49. public:
  50.   KDateTable(QWidget *parent=0, 
  51.          QDate date=QDate::currentDate(), 
  52.          const char *name=0, WFlags f=0);
  53.   ~KDateTable();
  54.   // Mirko, Mar 17 1998:
  55.   /** Returns a recommended size for the widget.
  56.     */
  57.   QSize sizeHint() const;
  58.   // ^^^^^^^^^^^^^^^^^^^
  59. public slots:
  60.   void goForward();
  61.   void goBackward();
  62.   // highstick: added May 13 1998
  63.   void goDown();
  64.   void goUp();
  65.   // Mirko, Mar 17 1998:
  66.   /** Sets the currently selected date. The date is
  67.     * only set if the given date is a valid one.
  68.     */
  69.   void setDate(QDate);
  70.   // ^^^^^^^^^^^^^^^^^^^
  71. signals:
  72.   void monthChanged(QDate);
  73.   void yearChanged(QDate);    // highstick: added May 13 1998
  74.   void dateSelected(QDate);
  75. protected:
  76.   void paintCell( QPainter *p, int row, int col );
  77.   void resizeEvent( QResizeEvent * );
  78.   void mousePressEvent(QMouseEvent *e);
  79.   const char* Days[7];
  80. private:
  81.   QDate m_date;
  82.   int m_firstDayOfWeek;
  83.   int m_daysInPrevMonth;
  84.   int m_oldRow;
  85.   int m_oldCol;
  86.   bool m_bSelection;
  87.   int m_selRow;
  88.   int m_selCol;
  89.  
  90.   void setSelection(int row, int col);
  91.   void getPrevMonth(QDate dtnow, QDate &dtprv);
  92.   void getNextMonth(QDate dtnow, QDate &dtnxt);
  93.   /** Returns the number of the day at position (row,col).
  94.     * The number is a negative one if the day is in the 
  95.     * previous month, and it is bigger than m_date.daysInMonth()
  96.     * if the day is in the next month.
  97.     */
  98.   int dayNum(int row, int col);
  99.   // highstick: added May 13 1998
  100.   void getPrevYear(QDate dtnow, QDate &dtprv);
  101.   void getNextYear(QDate dtnow, QDate &dtprv);
  102. private:  // Disabled copy constructor and operator=
  103.   KDateTable(const KDateTable & ) : QTableView() {}
  104.   KDateTable &operator=(const KDateTable &) { return *this; }
  105. };
  106.  
  107. #endif _KDATETBL_H
  108.